/**
 * @file
 * @author Filipe Mutz
 *
 * @section DESCRIPTION
 *
 */
#include "global.h"

#include <cmath>
#include <cstdlib>

namespace brain
{
	namespace global
	{
		double
		random_gaussian_radius(double std)
		{
			double norm = 1.0 / (RAND_MAX + 1.0);

			double u = 1.0 - rand() * norm; /* can't let u == 0 */
			double v = rand() * norm;
			double z = sqrt(-2.0 * log(u)) * cos(2.0 * M_PI * v);

			return (std * z);
		}


		double
		euclidean_distance(Point &p, Point &q)
		{
			double dist = 0;

			for(unsigned int i = 0; i < p.size(); i++)
				dist += pow(p[i] - q[i], 2);

			return sqrt(dist);
		}
	}
}
